<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Obaju : e-commerce template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="sourse/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="sourse/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Google fonts - Roboto -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700">
    <!-- owl carousel-->
    <link rel="stylesheet" href="sourse/vendor/owl.carousel/assets/owl.carousel.css">
    <link rel="stylesheet" href="sourse/vendor/owl.carousel/assets/owl.theme.default.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="sourse/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="sourse/css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="favicon.png">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
  </head>
  <body>
    <div id="all">
      <div id="content">
        <div class="container">
          <div class="row">
            <div id="checkout" class="col-lg-9">
              <div class="box">
                <form method="get">
                  <h1>选择支付方式</h1>
                  <div class="content py-3">
                    <div class="row">
                      <div class="col-md-6">
                        <div class="box payment-method">
                          <h4>Paypal</h4>
                          <p>We like it all.</p>
                          <div class="box-footer text-center">
                            <input type="radio" name="payment" value="payment1">
                          </div>
                        </div>
                      </div>
                      <div class="col-md-6">
                        <div class="box payment-method">
                          <h4>Payment gateway</h4>
                          <p>VISA and Mastercard only.</p>
                          <div class="box-footer text-center">
                            <input type="radio" name="payment" value="payment2">
                          </div>
                        </div>
                      </div>
                      <div class="col-md-6">
                        <div class="box payment-method">
                          <h4>Cash on delivery</h4>
                          <p>You pay when you get it.</p>
                          <div class="box-footer text-center">
                            <input type="radio" name="payment" value="payment3">
                          </div>
                        </div>
                      </div>
                    </div>
                    <!-- /.row-->
                  </div>
                  <!-- /.content-->
                  <div class="box-footer d-flex justify-content-between">
                    <button type="button" id="fk" class="btn btn-primary">付款<i class="fa fa-chevron-right"></i></button>
                  </div>
                </form>
                <!-- /.box-->
              </div>
            </div>
            <!-- /.col-lg-9-->
            <div class="col-lg-3">
              <div id="order-summary" class="card">
                <div class="card-header">
                  <h3 class="mt-4 mb-4">订单摘要</h3>
                </div>
                <div class="card-body">
                  <p class="text-muted">按照实际价格计算</p>
                  <div class="table-responsive">
                    <table class="table">
                      <tbody>
                      <tr>
                        <td>实付</td>
                        <th>￥${newSum}</th>
                      </tr>
                      <tr>
                        <td>折扣</td>
                        <th>￥${sum-newSum}</th>
                      </tr>
                      <tr class="total">
                        <td>总价</td>
                        <th>￥${sum}</th>
                      </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /#footer-->

    <script src="sourse/vendor/jquery/jquery.min.js"></script>
    <script src="sourse/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="sourse/vendor/jquery.cookie/jquery.cookie.js"> </script>
    <script src="sourse/vendor/owl.carousel/owl.carousel.min.js"></script>
    <script src="sourse/vendor/owl.carousel2.thumbs/owl.carousel2.thumbs.js"></script>
    <script src="sourse/js/front.js"></script>
  <script type="text/javascript">
      $("#fk").click(function () {
          if($("input[name='payment']:checked").length==0){
              alert("请选择支付方式")
          }else{
              $.ajax({
                  type:"post",
                  url:"payment",
                  data:{"payment":$("input[name='payment']:checked").val(),"oid":$("#oid",window.parent.document).attr("name")},
                  success:function (resl) {
                      if(resl == "0000"){
                          window.parent.location.href = "mini?ccid=4&oid="+$("#oid",window.parent.document).attr("name");
                      }else{
                          alert("付款失败")
                      }
                  }
              })
          }
      })
  </script>
  </body>
</html>